package top.zuli.package01.class06;

/**
 * 方法的重载，求两个数的和
 */
public class OverloadMethod {
    int sum(int a,int b){
        return a+b;
    }
    int sum(int a,int b,int c){
        return a+b+c;
    }
    double sum(double a,double b){
        return a+b;
    }
    double sum(double a,double b ,double c){
        return a+b+c;
    }

    public static void main(String[] args) {
        //创建对象
        OverloadMethod overloadMethod = new OverloadMethod();
        //调用方法:方法重载,优点：感觉上像是调用一个方法实现了多个功能，实际还是调用了多个方法。
        int result = overloadMethod.sum(1, 2);
        System.out.println(result);
        double result2 = overloadMethod.sum(1.1, 2.2);
        System.out.println(result2);
        int result3 = overloadMethod.sum(1, 2, 3);
        System.out.println(result3);
        double result4 = overloadMethod.sum(1.1,2.2,3.3);
        System.out.println(result4);
    }
}
